package com.wwj.admin.player.controller;

import com.github.pagehelper.Page;
import com.wwj.core.wawa.entity.PlayRecord;
import com.wwj.core.wawa.service.IPlayRecordService;
import com.wwj.framework.controller.BaseController;
import com.wwj.framework.utils.Page2EasyUiData;
import com.wwj.framework.utils.ReturnData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Auser on 2017/11/7.
 */
@Controller
@RequestMapping(value = "/play/record")
public class PlayRecordController extends BaseController {

    private final String INDEX = "/admin/player/record";

    @Resource
    private IPlayRecordService playRecordService;

    @RequestMapping(value = {"","/","/index"})
    public String index()throws Exception{
        return INDEX;
    }

    @RequestMapping("/listData.json")
    @ResponseBody
    public ReturnData list(String search,int limit,int offset)throws Exception{
        Map<String,Object> params = new HashMap<String,Object>();
        if(null != search && !"".equals(search)) params.put("search",search);
        Page<PlayRecord> records = playRecordService.findByPageUserInfo(params, offset, limit);
        return new ReturnData().success(Page2EasyUiData.format(records));
    }
}
